#ifndef READLINE_STUB_H
#define READLINE_STUB_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// Simple readline stub implementation for systems without readline
static inline char *readline(const char *prompt) {
    if (prompt) {
        fputs(prompt, stdout);
        fflush(stdout);
    }
    
    char *line = NULL;
    size_t len = 0;
    ssize_t read = getline(&line, &len, stdin);
    
    if (read == -1) {
        free(line);
        return NULL;
    }
    
    // Remove trailing newline
    if (read > 0 && line[read - 1] == '\n') {
        line[read - 1] = '\0';
    }
    
    return line;
}

static inline void add_history(const char *line) {
    // Stub: do nothing
    (void)line;
}

static inline int read_history(const char *filename) {
    // Stub: do nothing
    (void)filename;
    return 0;
}

static inline int write_history(const char *filename) {
    // Stub: do nothing
    (void)filename;
    return 0;
}

#endif // READLINE_STUB_H

